<?php

class Application_Model_Ecurie
{
	protected $_ecuNum;
	protected $_fpNum;
	protected $_ecuNom;
	protected $_ecuNomDir;
	protected $_ecuAdrSiege;
	protected $_ecuPoints;
	protected $_pays;
	protected $_ecuAdresseImage;

	public function __construct(array $options = null)
	{
		if(is_array($options))
		{
			$this->setOptions($options);
		}
	}
	
	public function __set($name, $value)
	{
		$method = 'set' . $name;
		if(('mapper' == $name) || !method_exists($this, $method))
		{
			throw new Exception('Invalid ecurie property');
		}
		$this->$method($value);
	}
	public function __get($name)
	{
		$method = 'get' . $name;
		if(('mapper' == $name) || !method_exists($this, $method))
		{
			throw new Exception('Invalid ecurie property');
		}
		return $this->$method();
	}

	public function setOptions(array $options)
	{
		$methods = get_class_methods($this);
		foreach ($options as $key => $value)
		{
			$method = 'set' . ucfirst($key);
			if(in_array($method, $methods))
			{
				$this->$method($value);
			}
		}
		return $this;
    }
	
    public function setEcuNum($ecuNum)
	{
		$this->_ecuNum = (int)$ecuNum;
		return $this;
	}
	public function getEcuNum()
	{
		return $this->_ecuNum;
	}
    
	public function setFpNum($fpNum)
	{
		$this->_fpNum = (int)$fpNum;
		return $this;
	}
	public function getFpNum()
	{
		return $this->_fpNum;
	}

	public function setEcuNom($ecuNom)
	{
		$this->_ecuNom = (string)$ecuNom;
		return $this;
	}
	public function getEcuNom()
	{
		return $this->_ecuNom;
	}

	public function setEcuNomDir($ecuNomDir)
	{
		$this->_ecuNomDir = (string)$ecuNomDir;
		return $this;
	}
	public function getEcuNomDir()
	{
		return $this->_ecuNomDir;
	}

	public function setEcuAdrSiege($ecuAdrSiege)
	{
		$this->_ecuAdrSiege = (string)$ecuAdrSiege;
		return $this;
	}
	public function getEcuAdrSiege()
	{
		return $this->_ecuAdrSiege;
	}
	
	public function setEcuPoints($ecuPoints)
	{
		$this->_ecuPoints = (int)$ecuPoints;
		return $this;
	}
	public function getEcuPoints()
	{
		return $this->_ecuPoints;
	}
	
	public function setPays($pays)
	{
		$this->_pays = $pays;
		return $this;
	}
	public function getPays()
	{
		return $this->_pays;
	}
	
	public function setEcuAdresseImage($ecuAdresseImage)
	{
		$this->_ecuAdresseImage = (string)$ecuAdresseImage;
		return $this;
	}
	public function getEcuAdresseImage()
	{
		return $this->_ecuAdresseImage;
	}
	
	public function toArray()
	{
		$tab = array();
		$tab['ecunum']=$this->_ecuNum;
		if(!is_null($this->_pays))
		{
			$tab['paynum']=$this->_pays->getPayNum();
		}
		$tab['ecunom']=$this->_ecuNom;
		$tab['ecunomdir']=$this->_ecuNomDir;
		$tab['fpnum']=$this->_fpNum;
		$tab['ecuadrsiege']=$this->_ecuAdrSiege;
		$tab['ecupoints']=$this->_ecuPoints;
		$tab['ecuadresseimage']=$this->_ecuAdresseImage;
		
		return $tab;
	}
}